package com.lq.schoolshop.controller.before;

import com.lq.schoolshop.bean.Result;
import com.lq.schoolshop.bean.StatusCode;
import com.lq.schoolshop.pojo.Expand.ShopAndGoods;
import com.lq.schoolshop.service.ShopCarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author
 * @Date2021/1/15 13:58
 * @Version V1.0
 *   购物车点击结算  商品结算页面
 **/
@Api(value = "商城前台功能--购物结算模块",tags = "商城前台功能--购物结算模块")
@RequestMapping("account")
@Controller
public class ForAccountController {

    @Autowired
    private ShopCarService shopCarService;

    //1.显示所有需要结算的商品的清单
    @ApiOperation(value = "显示结算商品信息",notes = "显示所有需要结算的商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "勾选商品ID",dataType = "String[]",required = true,paramType = "query"),
    })
    @ResponseBody
    @RequestMapping(value = "/ShowAllAcount",method = RequestMethod.GET)
    public Result ShowAllAcount(@RequestParam("id") String[]id) {
        Result result = null;
        if (id.length <= 0) {
            result = new Result(false, StatusCode.OK, "请传入参数");
        } else {
            int[] intnum = new int[id.length];
            for (int i = 0; i < id.length; i++) {
                intnum[i] = Integer.parseInt(id[i]);
            }
            List<ShopAndGoods> shopAndGoods = shopCarService.selByShopId(intnum);
            result = new Result(true,StatusCode.OK,"成功显示结算商品",shopAndGoods);
        }
        return result;
    }

    //2.提交需要结算的商品的清单



}
